-------------------------------------------------------------------------------
-- Визуальное сравнение файлов (VisComp.dll © Максим Русов). © SimSU
-------------------------------------------------------------------------------
local GUIDviscomp = "AF4DAB38-C00A-4653-900E-7A8230308010"
if not Plugin.Exist(GUIDviscomp) then return end

---- Настройки
local function Settings()
-- Начало файла Profile\SimSU\Plugin_VisualCompare.cfg
return{
  Key="AltC"; --Prior=50;
}
-- Конец файла Profile\SimSU\Plugin_VisualCompare.cfg
end

---- Локализация
_G.far.lang=far.lang or win.GetEnv("farlang")
-- Встроенные языки / Buildin laguages
local function Messages()
if far.lang=="Russian" then
-- Начало файла Profile\SimSU\Plugin_VisualCompareRussian.lng
return{
  Descr="Визуальное сравнение файлов (VisComp.dll © Max Rusov). © SimSU";
}
-- Конец файла Profile\SimSU\Plugin_VisualCompareRussian.lng
else--if far.lang=="English" then
-- Begin of file Profile\SimSU\Plugin_VisualCompareEnglish.lng
return{
  Descr="Visual comparison of files (VisComp.dll © Max Rusov). © SimSU";
}
-- End of file Profile\SimSU\Plugin_VisualCompareEnglish.lng
end end

local M=(loadfile(win.GetEnv("FARPROFILE").."\\SimSU\\Plugin_VisualCompare"..far.lang..".lng") or Messages)()
local S=(loadfile(win.GetEnv("FARLOCALPROFILE").."\\SimSU\\Plugin_VisualCompare.cfg") or loadfile(win.GetEnv("FARPROFILE").."\\SimSU\\Plugin_VisualCompare.cfg") or Settings)()

local SimSU=SimSU or {}
-------------------------------------------------------------------------------
function SimSU.Plugin_VisualCompare(LeftFile,RightFile)
  if LeftFile and RightFile then
    Plugin.Command(GUIDviscomp,"\""..LeftFile.."\" \""..RightFile.."\"")
  elseif APanel.SelCount==2 then
    Plugin.Command(GUIDviscomp,"\""..panel.GetSelectedPanelItem(nil,1,1).FileName.."\" \""..panel.GetSelectedPanelItem(nil,1,2).FileName.."\"")
  else
    if APanel.Left then
      Plugin.Command(GUIDviscomp,"\""..(APanel.Path~="" and APanel.Path.."\\"..APanel.Current or APanel.Current).."\" \""..(PPanel.Path~="" and PPanel.Path.."\\"..PPanel.Current or PPanel.Current).."\"")
    else
      Plugin.Command(GUIDviscomp,"\""..(PPanel.Path~="" and PPanel.Path.."\\"..PPanel.Current or PPanel.Current).."\" \""..(APanel.Path~="" and APanel.Path.."\\"..APanel.Current or APanel.Current).."\"")
    end
  end
end
-------------------------------------------------------------------------------
if not Macro then return {Plugin_VisualCompare=SimSU.Plugin_VisualCompare} end

local ok, mod = pcall(require,"SimSU.Plugin_VisualCompare"); if ok then SimSU=mod else _G.SimSU=SimSU end
-------------------------------------------------------------------------------

Macro {area="Shell"; key=S.Key; priority=S.Prior; description=M.Descr;
  condition=function() return Plugin.Exist(GUIDviscomp) and (APanel.SelCount==2 or (APanel.Visible and not APanel.Folder and PPanel.Visible and not PPanel.Folder)) end;
  action=SimSU.Plugin_VisualCompare;
}
